﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    public String name;
    public String pass;
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Validate();
        
    }
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection();
        name = Login1.UserName;
        pass = Login1.Password;
        try
        {
            
            con.ConnectionString = "Data Source=ACER-PC;Initial Catalog=graduate_manage;Integrated Security=True";
            con.Open(); 
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "select count(*) GRADUATE_PASSWORD  from GRADUATE_PSWD where GRA_ID='" + name + "' and GRADUATE_PASSWORD = '" + pass + "'";
            int countxing;
            SqlDataReader read = cmd.ExecuteReader();

            read.Read(); 
            countxing = read.GetInt32(0);
            MessageBox.Show("open");
            
            read.Close();

            if (countxing > 0)
            {
                Response.Redirect("~/HomePage.aspx?username = @name", true);//!!
            }
            else
            {
                
                MessageBox.Show("用户名或密码错误！", "ERROR");

            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        finally
        {
            con.Close();
        }
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write(name);
    }
}
     
